package com.only4play.portal.cp.api;

import com.only4play.portal.common.error.PortalErrorException;
import com.only4play.portal.common.service.ApiService;
import com.only4play.portal.common.session.PortalSession;
import com.only4play.portal.common.session.PortalSessionManager;
import com.only4play.portal.cp.config.CpConfigStorage;

/**
 * @author liyuncong
 * @version 1.0
 * @file PortalCpService
 * @brief PortalCpService
 * @details PortalCpService
 * @date 2024-06-07
 *
 * Edit History
 * ----------------------------------------------------------------------------
 * DATE                     NAME               DESCRIPTION
 * 2024-06-07               liyuncong          Created
 */
public interface CpService extends ApiService {

    /**
     * 验证推送过来的消息的正确性
     *
     * @param msgSignature
     * @param timestamp
     * @param nonce
     * @param data
     * @return
     */
    boolean checkSignature(String msgSignature, String timestamp, String nonce, String data);

    /**
     * 获取access_token, 不强制刷新access_token
     *
     * @return
     * @throws Exception
     */
    String getAccessToken() throws PortalErrorException;

    /**
     * 获取access_token，本方法线程安全
     *
     * @param forceRefresh
     * @return
     * @throws Exception
     */
    String getAccessToken(boolean forceRefresh) throws PortalErrorException;

    PortalSession getSession(String id);

    PortalSession getSession(String id, boolean create);

    PortalSessionManager getSessionManager();

    void setSessionManager(PortalSessionManager sessionManager);

    /**
     * Initialization http
     */
    void initHttp();

    CpConfigStorage getCpConfigStorage();

    void setCpConfigStorage(CpConfigStorage configStorage);
}
